#pragma once

#include <vector>

namespace DuiLib
{
	typedef unsigned int UInt;

	enum { FileType_File, FileType_Dir };

	struct CFileInfo
	{
		CDuiString name;
		UInt size;
		UInt type;

		CFileInfo(const CDuiString& _name, size_t _size, UInt _type)
		{
			name = _name;
			size = _size;
			type = _type;
		}
	};

	typedef std::vector<CFileInfo> FileInfoVector;

	// QDirModel
	class UILIB_API CDirModel : public CCommonTreeModel
	{
	public:

	public:
		CDirModel(const CDuiString& root, const CDuiString& filter=_T("*.*"));
		CDirModel() = delete;
		~CDirModel();

		//CModelIndex index(const CDuiString& path, int column = 0);
		bool findDir(const CDuiString& path);

		CDuiString filePath(const CModelIndex& index);
		CDuiString fileName(const CModelIndex& index);

		void ParseDir(const CModelIndex& index);

	private:
		FileInfoVector getFilesInDir(const CDuiString& path, const CDuiString& fileter);
		
	private:
		CDuiString m_RootPath;
		CDuiString m_Filter;

	};

}